import * as THREE from 'three';
import { BufferGeometry, Vector3 } from 'three';
import { LineGeometry } from 'three/examples/jsm/lines/LineGeometry.js';

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);

const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshBasicMaterial({ color: 'red' });
const cube = new THREE.Mesh(geometry, material);
// scene.add(cube)

var lineGeo = new LineGeometry();
lineGeo.setPositions([0, 0, 0, 100, 100, 100]);
const lineMesh = new THREE.Line(lineGeo, material)
scene.add(lineMesh)

setTimeout(() => {
    // lineMesh.geometry = new BufferGeometry();
    lineGeo.setPositions([0, 0, 0, 50, 50, 50]);
    // lineMesh.geometry.setFromPoints([new Vector3(0, 0, 0), new Vector3(10, 10, 10)]);
}, 2000);

camera.position.z = 100;

function animate() {
    requestAnimationFrame(animate);
    renderer.render(scene, camera);
}
animate()

//
// private _mousemoveWhenWireFrame(event: MouseEvent) {
// 	const me = this
// 	if (me._plane && me._platform) {
// 		pointer.set((event.offsetX / window.innerWidth) * 2 - 1, - (event.offsetY / window.innerHeight) * 2 + 1);

// 		raycaster.setFromCamera(pointer, camera);

// 		const intersects = raycaster.intersectObjects([me._plane], false);

// 		if (intersects.length > 0) {
// 			const intersect = intersects[0]
// 			if (intersect) {
// 				const point = new Vector3(0, 0, 0)
// 				point.copy(intersect.point).add(intersect.face!.normal);
// 				point.divideScalar(10).floor().multiplyScalar(10).addScalar(10);
// 				const planeGeo = new PlaneGeometry(Math.abs(point.x * 2), Math.abs(point.z * 2))
// 				me._platform.geometry = planeGeo
// 			}
// 		}
// 	}
// }